package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.model.entity.*;
import com.atguigu.lease.web.admin.mapper.LeaseAgreementMapper;
import com.atguigu.lease.web.admin.service.*;
import com.atguigu.lease.web.admin.vo.agreement.AgreementQueryVo;
import com.atguigu.lease.web.admin.vo.agreement.AgreementVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liubo
 * @description 针对表【lease_agreement(租约信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class LeaseAgreementServiceImpl extends ServiceImpl<LeaseAgreementMapper, LeaseAgreement>
        implements LeaseAgreementService {
@Autowired
private LeaseAgreementMapper leaseAgreementMapper;
@Autowired
    ApartmentInfoService apartmentInfoService;
@Autowired
    PaymentTypeService paymentTypeService;
@Autowired
    LeaseTermService leaseTermService;
@Autowired
RoomInfoService roomInfoService;
    @Override
    public IPage<AgreementVo> selectpage(IPage<AgreementVo> objectPage, AgreementQueryVo queryVo) {
        IPage<AgreementVo> agreementVoIPage=leaseAgreementMapper.selectpages(objectPage, queryVo);
        return agreementVoIPage;
    }

    @Override
    public AgreementVo getAgreementVo(Long id) {

        LeaseAgreement byId = super.getById(id);
        ApartmentInfo byId1 = apartmentInfoService.getById(id);
        PaymentType byId2 = paymentTypeService.getById(id);
        LeaseTerm byId3 = leaseTermService.getById(id);
        RoomInfo byId4 = roomInfoService.getById(id);
        AgreementVo agreementVo = new AgreementVo();
        BeanUtils.copyProperties(byId, agreementVo);
        agreementVo.setApartmentInfo(byId1);
        agreementVo.setPaymentType(byId2);
        agreementVo.setLeaseTerm(byId3);
        agreementVo.setRoomInfo(byId4);

        return agreementVo;
    }
}




